package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.PromotionPreGoodsSpu;
import com.jic.market.mapper.PromotionPreGoodsSpuMapper;
import com.jic.market.service.PromotionPreGoodsSpuService;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.Page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 预售商品表SPU表
 * @author : 
 * @email : 
 * @since : 2020-03-28 11:30:20
 * @version : v1.0.0
 */
@Service
public class PromotionPreGoodsSpuServiceImpl implements PromotionPreGoodsSpuService{

    @Autowired
    private PromotionPreGoodsSpuMapper promotionPreGoodsSpuMapper;

    @Override
    public long insert(PromotionPreGoodsSpu promotionPreGoodsSpu) {
        long flag = promotionPreGoodsSpuMapper.insert(promotionPreGoodsSpu);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return promotionPreGoodsSpuMapper.delete(id);
    }

    @Override
    public long update(PromotionPreGoodsSpu promotionPreGoodsSpu) {
        return promotionPreGoodsSpuMapper.update(promotionPreGoodsSpu);
    }

    @Override
    public PromotionPreGoodsSpu queryByPrimaryKey(Long id){
        return promotionPreGoodsSpuMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<PromotionPreGoodsSpu> query(PromotionPreGoodsSpu promotionPreGoodsSpu){
        return promotionPreGoodsSpuMapper.query(promotionPreGoodsSpu);
    }

    @Override
    public PageResult<PromotionPreGoodsSpu> queryPage(PromotionPreGoodsSpu promotionPreGoodsSpu, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<PromotionPreGoodsSpu> list = promotionPreGoodsSpuMapper.queryPage(startIndex, pageQuery.getLimit(), promotionPreGoodsSpu);
        long count = promotionPreGoodsSpuMapper.queryPageCount(promotionPreGoodsSpu);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}